package com.xk._02算法篇._01sort;

import com.xk._02算法篇._01sort.sort.CountingSort1;
import com.xk._02算法篇._01sort.sort.CountingSort2;
import com.xk._02算法篇._01sort.sort.RadixSort;
import com.xk._02算法篇._01sort.sort.Sort;
import com.xk.tools.Asserts;
import com.xk.tools.Integers;

import java.util.Arrays;

/**
 * @description:
 * @author: xu
 * @date: 2022/10/1 1:59
 */
public class Main {
    public static void main(String[] args) {
        test01();
    }

    static void test01(){
        //Integer[] array = Integers.random(1 << 16, 1, 200000);
        Integer[] array = {7,3,5,8,6,7,4,5};
        Integer[] array1 = Integers.random(1000, 1, 10000);

        testSorts(array1,
                new CountingSort1(),
                new CountingSort2(),
                new RadixSort()
                //new ShellSort1<Integer>(),
                //new ShellSort2<Integer>(),
                //new QuickSort<Integer>(),
                //new MergeSort<Integer>(),
                //new InsertionSort1<Integer>(),
                //new InsertionSort2<Integer>(),
                //new InsertionSort3<Integer>(),
                //new HeapSort<Integer>()
                //new SelectionSort1<Integer>(),
                //new BubbleSort1<Integer>(),
                //new BubbleSort2<Integer>(),
                //new BubbleSort3<Integer>()
        );
    }

    static void testSorts(Integer[] array, Sort... sorts) {
        for (Sort sort : sorts) {
            Integer[] newArray = Integers.copy(array);
            sort.sort(newArray);
            Asserts.test(Integers.isAscOrder(newArray));
        }
        Arrays.sort(sorts);
        for (Sort sort : sorts) {
            System.out.println(sort);
        }
    }
}
